package com.zzf.工厂模式;

import com.zzf.工厂模式.impl.Apple;
import com.zzf.工厂模式.impl.Orange;
import com.zzf.工厂模式.impl.Peach;
import com.zzf.工厂模式.impl.WaterMelon;

public class FruitFactory {
    public static final int CREATE_APPLE = 1;
    public static final int CREATE_ORANGE = 2;
    public static final int CREATE_PEACH = 3;
    public static final int CREATE_WATERMELON = 4;

    public static Fruit createFruit(int fruit){
        switch(fruit){
            case CREATE_APPLE:
                return new Apple();

            case CREATE_ORANGE:
                return new Orange();

            case CREATE_PEACH:
                return new Peach();

            case CREATE_WATERMELON:
                return new WaterMelon();

            default:
                System.out.println("没有该水果");
                return null;
        }
    }


    private FruitFactory(){

    }

}
